package org.jeecg.modules.area.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.area.entity.Area;
import org.jeecg.modules.area.mapper.AreaMapper;
import org.jeecg.modules.area.service.AreaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 行政区域数据 服务实现类
 * </p>
 *
 * @author liujiamiao
 * @since 2020-11-18
 */
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {

    /**
     * 根据城市名称获取城市编码
     * @param city
     * @return
     */
    @Override
    public String findCityCodeByCityName(String city) {
        if(city.indexOf("市")==-1){
            city+="市";
        }
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("sca_name",city);
        Area area = this.getOne(wrapper);
        System.out.println("area = "+area);
        if(area==null){
            return null;
        }
        return area.getScaId().toString();
    }
}
